package com.longge;

import java.util.HashSet;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-03-07 23:47
 */
public class FindRepeatNumber {

    public int findRepeatNumber(int[] nums) {

        HashSet<Integer> noRepeat = new HashSet<>();
        int res = 0;
        for (int i = 0; i < nums.length; i++) {
            int oldSize = noRepeat.size();
            noRepeat.add(nums[i]);
            int newSize = noRepeat.size();
            if (oldSize != newSize) continue;
            res = nums[i];
            break;

        }
        return res;
    }
}
